home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / ip / trace / tcpdump-2.2.1 / print-sunrpc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-02  |  3.2 KB  |  137 lines

  1. /*
  2.  * Copyright (c) 1992 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that: (1) source code distributions
  7.  * retain the above copyright notice and this paragraph in its entirety, (2)
  8.  * distributions including binary code include the above copyright notice and
  9.  * this paragraph in its entirety in the documentation or other materials
  10.  * provided with the distribution, and (3) all advertising materials mentioning
  11.  * features or use of this software display the following acknowledgement:
  12.  * ``This product includes software developed by the University of California,
  13.  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
  14.  * the University nor the names of its contributors may be used to endorse
  15.  * or promote products derived from this software without specific prior
  16.  * written permission.
  17.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  18.  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  19.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  20.  */
  21.  
  22. #ifndef lint
  23. static char rcsid[] =
  24.     "@(#) $Header: print-sunrpc.c,v 1.1 92/06/02 11:36:37 mccanne Exp $ (LBL)";
  25. #endif
  26.  
  27. #include <stdio.h>
  28. #include <sys/param.h>
  29. #include <sys/types.h>
  30. #include <sys/socket.h>
  31. #include <net/if.h>
  32. #include <netinet/in.h>
  33. #include <netinet/if_ether.h>
  34. #include <netinet/in_systm.h>
  35. #include <netinet/ip.h>
  36. #include <netinet/ip_var.h>
  37.  
  38. #include <sys/time.h>
  39. #include <errno.h>
  40. #include <rpc/types.h>
  41. #include <rpc/auth.h>
  42. #include <rpc/auth_unix.h>
  43. #include <rpc/svc.h>
  44. #include <rpc/xdr.h>
  45. #include <rpc/rpc_msg.h>
  46.  
  47. #include <rpc/pmap_prot.h>
  48.  
  49. #include <ctype.h>
  50.  
  51. #include "interface.h"
  52.  
  53. #include "addrtoname.h"
  54. #include "extract.h"
  55.  
  56. #if BYTE_ORDER == LITTLE_ENDIAN
  57. /*
  58.  * Byte swap an array of n words.
  59.  * Assume input is word-aligned.
  60.  * Check that buffer is bounded by "snapend".
  61.  */
  62. static void
  63. bswap(bp, n)
  64.     register u_long *bp;
  65.     register u_int n;
  66. {
  67.     register int nwords = ((char *)snapend - (char *)bp) / sizeof(*bp);
  68.  
  69.     if (nwords > n)
  70.         nwords = n;
  71.     for (; --nwords >= 0; ++bp)
  72.         *bp = ntohl(*bp);
  73. }
  74. #endif
  75.  
  76. void
  77. sunrpcrequest_print(rp, length, ip)
  78.     register struct rpc_msg *rp;
  79.     int length;
  80.     register struct ip *ip;
  81. {
  82.     register u_long *dp;
  83.     register u_char *ep = snapend;
  84. #define TCHECK(p, l) if ((u_char *)(p) > ep - l) break
  85.  
  86. #if BYTE_ORDER == LITTLE_ENDIAN
  87.     bswap((u_long *)rp, sizeof(*rp) / sizeof(u_long));
  88. #endif
  89.  
  90.     if (!nflag)
  91.         (void)printf("%s.%x > %s.sunrpc: %d",
  92.                  ipaddr_string(&ip->ip_src),
  93.                  rp->rm_xid,
  94.                  ipaddr_string(&ip->ip_dst),
  95.                  length);
  96.     else
  97.         (void)printf("%s.%x > %s.%x: %d",
  98.                  ipaddr_string(&ip->ip_src),
  99.                  rp->rm_xid,
  100.                  ipaddr_string(&ip->ip_dst),
  101.                  PMAPPORT,
  102.                  length);
  103.  
  104.     switch (rp->rm_call.cb_proc) {
  105.  
  106.     case PMAPPROC_NULL:
  107.         printf(" null");
  108.         break;
  109.  
  110.     case PMAPPROC_SET:
  111.         printf(" set");
  112.         break;
  113.  
  114.     case PMAPPROC_UNSET:
  115.         printf(" unset");
  116.         break;
  117.  
  118.     case PMAPPROC_GETPORT:
  119.         printf(" getport");
  120.         break;
  121.  
  122.     case PMAPPROC_DUMP:
  123.         printf(" dump");
  124.         break;
  125.  
  126.     case PMAPPROC_CALLIT:
  127.         printf(" callit");
  128.         break;
  129.  
  130.     default:
  131.         printf(" proc #%d", rp->rm_call.cb_proc);
  132.     }
  133.     printf(" prog #%d", rp->rm_call.cb_prog);
  134.     putchar('\n');
  135. }
  136.  
  137.